package com.song.tools.mvc.controller;

import com.song.tools.core.beans.response.ResultVo;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * POI控制器
 *
 * @author song tools
 * @since 2024-06-25
 */
public interface PoiController<QueryRequest> {

    /**
     * 导入
     */
    @PostMapping("/import")
    @Operation(summary = "导入")
    ResultVo<Boolean> importExcel(@RequestPart("file") MultipartFile file);

    /**
     * 获取导入模版
     */
    @PostMapping("/importTpl")
    @Operation(summary = "获取导入模版")
    void importTpl(HttpServletResponse response) throws IOException;


    /**
     * 导出
     */
    @PostMapping("/export")
    @Operation(summary = "导出")
    void exportExcel(HttpServletResponse response, @RequestBody QueryRequest request) throws IOException;

    /**
     * 异步导出
     */
    @PostMapping("/asyncExport")
    @Operation(summary = "异步导出")
    default ResultVo<Boolean> asyncExportExcel(@RequestBody QueryRequest request) throws IOException {
        throw new UnsupportedOperationException();
    }
}
